package com.sanerzone.smscenter.modules.sms.task;

import com.sanerzone.jeebase.common.utils.DateUtils;
import com.sanerzone.smscenter.modules.sms.service.SmsSendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
@Lazy(false)
public class SmsSendCheatTask {
    private static Logger logger = LoggerFactory.getLogger(SmsSendCheatTask.class);

    @Autowired
    private SmsSendService smsSendService;

    @Scheduled(cron = "* 0/10 * * * ? ")
    @Transactional(readOnly = false)
    public void execSmsCheat(){
        try {
            logger.info( "自动比例发送任务执行中。" );
            String tableName = "sms_send_"+DateUtils.getDayOfMonth(0);
            Map map=new HashMap( );
            map.put( "tableName",tableName );
            smsSendService.updateCheatSmssend( map );
        }catch (Exception e){
            e.printStackTrace();
            logger.error( "自动比例发送失败！" );

        }


    }





}
